package com.cy.pj.sys.web.controller;

import com.cy.pj.sys.pojo.SysNotice;
import com.cy.pj.sys.service.SysNoticeService;
import com.cy.pj.sys.web.pojo.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sun.java2d.pipe.SpanIterator;

import java.util.List;

@RequestMapping("/notice/")
@RestController
public class SysNoticeController {
    @Autowired
    private SysNoticeService sysNoticeService;
    @GetMapping("/doFindNotices")
    //http://localhost:8080/notice/doFindNotices?type=1&modifiedUser=tony
    public JsonResult doFindNotices(SysNotice notice){
        return new JsonResult(sysNoticeService.findNotices(notice));
    }
    @PostMapping("/doSaveNotice")
    @ResponseBody
    public JsonResult doSaveNotice(SysNotice notice){
        sysNoticeService.saveNotice(notice);
        return new JsonResult("save ok");
    }
    @GetMapping("/doFindById/{id}")
    @ResponseBody
    public JsonResult doFindById(@PathVariable Long id){
        return new JsonResult(sysNoticeService.findById(id));
    }
    @PutMapping("/doUpdateNotice")
    @ResponseBody
    public JsonResult doUpdateNotice(SysNotice notice){
        sysNoticeService.updateNotice(notice);
        System.out.println("update ok");
        return new JsonResult("update ok");
    }
    @DeleteMapping("/doDeleteById/{ids}")
    @ResponseBody
    public JsonResult doDeleteById(@PathVariable  Long... ids){
        sysNoticeService.deleteById(ids);
        return new JsonResult("delete ok");
    }
}
